package com.genghis.ptas.security.service.impl;

import com.genghis.core.page.dao.PageDao;
import com.genghis.ptas.constant.DictConstant;
import com.genghis.ptas.friend.dao.FriendDao;
import com.genghis.ptas.friend.entity.Friend;
import com.genghis.ptas.security.entity.User;
import com.genghis.ptas.security.service.SessionService;
import com.genghis.ptas.security.service.UserService;
import com.genghis.ptas.util.LoginUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * User: gaoyang
 * To change this template use File | Settings | File Templates.
 */
@Service("sessionService")
public class SessionServiceImpl implements SessionService {
    @Autowired
    private UserService userService;

    @Autowired
    private FriendDao friendDao;

    @Override
    public User findFullUserByUserLoginName() {
        String loginName = LoginUserUtil.findLoginUserName();
        return null == loginName ? null : userService.findFullUserByUserLoginName(loginName);
    }

    @Override
    public void editFriendInfoByUserId(User user) {
        if(null!=user)
            friendDao.editFriendInfoByUserId(new Friend(user.getId(), DictConstant.MINUS_ONE, DictConstant.STATE_IN_USE));
    }
}
